<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ include file="include.inc.jsp"  %>
<html>
<head>
    <title></title>
    <link href="lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="common/style.css" rel="stylesheet" type="text/css" />
    <script src="common/common.js" type="text/javascript"></script>
    
    <script src="lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
    <!-- <script src="lib/ligerUI/js/core/base.js" type="text/javascript"></script> 
    <script src="lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
    <script src="lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
    <script src="lib/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script> 
    <script src="lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script> -->
    <script type="text/javascript">
    
	    function deleteRow(){ 
	        //manager.deleteSelectedRow();
	        $.ligerDialog.warn('删除后不可恢复，暂时不能删除！');
	    }
	    
	    function editAdd(){//添加
    		var title='收购黄金添加';
	    	$.ligerDialog.open({width:600,height:460,url:'${ctx}/acquisitionGold/purchaseGoldAdd?operator=0',title:title});
	    }
	    
	    function edit(id){
	    	var rowData=manager.getRow(id);
    		var title='收购黄金修改';
	    	window.customer={cName:rowData.c_name};
	    	$.ligerDialog.open({width:600,height:460,url:'${ctx}/acquisitionGold/purchaseGoldAdd?id='+rowData.pg_id+'&c_Id='+rowData.c_id+'&operator=1',title:title});
	    }

	    
	    var manager=null;
	    var form=null;
        $(function () {
        	//生成表格
            manager=$("#maingrid").ligerGrid({
                columns: [
				{ display: '客户名称', name: 'c_name', align: 'left', width: 100, minWidth: 60 },
				{ display: '黄金名称', name: 'g_name', align: 'left', width: 100, minWidth: 60 },
                { display: '收购黄金表id', name: 'pg_id', align: 'left', width: 100, minWidth: 60 },
                { display: '收购的金属id', name: 'g_id', minWidth: 120 },
                { display: '收购黄金的单号', name: 'pg_number', minWidth: 140 },
                { display: '收购黄金的价格（单价）', name: 'pg_price',width:'auto' },
                { display: '收购黄金的重量', name: 'pg_weight',width:'auto' },
                { display: '收购黄金的总金额', name: 'pg_cost',width:'auto' },
                { display: '收购客户的id，如果是散户为null', name: 'c_id',width:'auto' },
                { display: '收购日期', name: 'pg_timechar',width:'auto' },
                { display: '收购时，实际付的金额', name: 'pg_pay',width:'auto' },
                { display: '收购时，未付的金额', name: 'pg_owe',width:'auto' },
                { display: '收购黄金时，单号状态', name: 'pg_state',width:'auto' },
                { display: '预留字段', name: 'pg_type',width:'auto' },
                { display: '更新时间', name: 'pg_updatechar',width:'auto' },
                { display: '操作', name:'',isSort: false, width: 120, render: function (rowdata, rowindex, value){
                		//console.log(rowdata);console.log(rowindex);console.log(value);
                        return "<a href='javascript:void(0)' onclick='edit(\""+ rowindex + "\")'>修改</a> ";;
                    }
                 }
                ], 
                sortName: 'pg_id',
                checkbox:true,
                usePager:true,
                url:'${ctx}/acquisitionGold/purchaseGoldGrid',
                onSuccess:function(data,grid){
                	data.Rows=data.rows;
                	data.Total=data.records;
                }
            });
            $("#pageloading").hide();
            
          //创建表单结构 
            form=$("#form").ligerForm({
                //inputWidth: 170, labelWidth: 90, space: 40,
                height:28,
                fields: [
                { name: "gId", type: "hidden" },
                { display: "名称", name: "gName", newline: false, type: "text"/* , groupicon: groupicon */},
                { display: "市场价", name: "gPrice", newline: false, type: "number"},
                { display: "单位 ", name: "gUnit", newline: false, type: "text"  },
                { display: "零售价", name: "gSaleprice", newline: false, type: "number" },
                { display: "备注", name: "gMemo", newline: false, type: "text"}
                ]
            });
        });
    </script>
</head>
<body style="overflow-x:hidden">
<div class="l-loading" style="display:block" id="pageloading"></div>
<div class="container">
	<div style="padding:10px">
		<form id="search_div">
			客户名称：<input type="text" name="cName">
			黄金名称：<input type="text" name="gName">
			开始时间：<input type="text" name="beginDate">
			结束时间：<input type="text" name="endDate">
		</form>
		<button onclick="search('search_div',manager)">搜索</button>
	</div>
	
	<div id="maingrid"></div>
	<h5>
		<button onclick="editAdd()" type="button" class="btn btn-primary">添加</button>
		<button onclick="deleteRow()" type="button" class="btn btn-primary">删除</button>
	</h5>	
</div>
<div style="display:none" id="target">
<div id="form"></div>
<div class="highlight">
<button onclick="$('.l-dialog-close').trigger('click')" style="float:right;margin-right:15px" type="button" class="btn btn-default">取消</button>
<button onclick='save()' style="float:right;margin-right:15px" type="button" class="btn btn-primary">保存</button>
</div>
	
</div>
</body>
</html>
